export default {
	/**
	 * date: 不传默认当前
	 * t: year/month/day/hour/minte/second
	 */
	getCurDate(date,t) {
		let year = date.getFullYear();
		let month = date.getMonth() + 1;
		let day = date.getDate();
		let hour = date.getHours();
		let minute = date.getMinutes();
		let second = date.getSeconds();
		// 不足两位，添“0”
		month = month < 10 ? '0' + month : month;
		day = day < 10 ? '0' + day : day;
		hour = hour < 10 ? '0' + hour : hour;
		minute = minute < 10 ? '0' + minute : minute;
		second = second < 10 ? '0' + second : second;
		switch(t) {
			case "year":
				return year;
				break;
			case "month":
				return year + '-' + month;
				break;
			case "day":
				return year + '-' + month + '-' + day;
				break;
			case "hour":
				return year + '-' + month + '-' + day + ' ' + hour;
				break;
			case "minute":
				return year + '-' + month + '-' + day + ' ' + hour + ':' + minute;
				break;
			default:
				return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
				break;
		}
	}
}